package com.wcy.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.util.List;

import com.wcy.annotation.pageVo.MappingColumn;
import com.wcy.annotation.pageVo.PageColumn;
import com.wcy.annotation.pageVo.PageName;
import com.wcy.annotation.pageVo.SelectionAnnotation;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

/**
 * <p>
 * 
 * </p>
 *
 * @author 吴传亿
 * @since 2025-04-28
 */
@Getter
@Setter
@ToString
@Accessors(chain = true)
@PageName(name = "用户")
public class User {

    @PageColumn(isId = true,prop="userId", label="用户ID",allowEdit = false)
    @TableId(value = "user_id", type = IdType.AUTO)
    private Integer userId;

    @PageColumn(prop="avatar",label="用户头像",type="img",url="user/upload",fetchUrl = "user/download/")
    private String avatar;

    @PageColumn(prop="username", label="用户名")
    private String username;

    @PageColumn(prop="password", label="密码",type = "password")
    private String password;

    @PageColumn(prop="email", label="邮箱")
    private String email;

    @PageColumn(prop="phone", label="手机号")
    private String phone;

    @PageColumn(prop="createdAt", label="创建时间",type = "date-picker",allowEdit = false)
    private LocalDateTime createdAt;

    @PageColumn(prop="updatedAt", label="更新时间",type = "date-picker",allowEdit = false)
    private LocalDateTime updatedAt;

    @PageColumn(prop="lastLogin", label="最后登录时间",type = "date-picker",allowEdit = false)
    private LocalDateTime lastLogin;

    @PageColumn(prop="roles",  label="角色",type = "mapping",mappingRef = @MappingColumn(targetProp = "userId",mappingByPropUrl = "userRole/list",mappingListUrl = "role/list",mappingListProp = "roleId",mappingListLabel = "roleName"))
    @TableField(exist = false)
    private List<UserRole> roles;
}
